package com.wbk.lotterysystemuserservice.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.wbk.lotterysystemuserservice.commons.bo.UserLoginBO;
import com.wbk.lotterysystemuserservice.commons.bo.UserRegisterBO;
import com.wbk.lotterysystemuserservice.commons.bo.UserResetBO;
import com.wbk.lotterysystemuserservice.commons.dto.UserLoginDTO;
import com.wbk.lotterysystemuserservice.controller.biz.UserInfoBiz;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;
import result.Result;

import javax.validation.Valid;

@Api
@RestController
@RequestMapping("/user/api/user")
public class UserInfoController {

    @Autowired
    UserInfoBiz userInfoBiz;

    @ApiOperation(value = "用户登录接口", notes = "用户登录")
    @PostMapping("/login")
    public Result<UserLoginDTO> login(@Valid @RequestBody UserLoginBO userLoginBO) {
        return userInfoBiz.login(userLoginBO);
    }

    @ApiOperation(value = "用户注册接口", notes = "用户注册")
    @PostMapping("/register")
    public Result<UserLoginDTO> register(@Valid @RequestBody UserRegisterBO userRegisterBO) {
        return userInfoBiz.register(userRegisterBO);
    }

    @ApiOperation(value = "用户修改密码接口", notes = "用户修改密码")
    @PostMapping("/reset")
    public Result reset(@Valid @RequestBody UserResetBO userResetBO) {
        return userInfoBiz.reset(userResetBO);
    }

    @ApiOperation(value = "解析token接口", notes = "解析token")
    @GetMapping("/testToken")
    public Result<UserLoginDTO> token(@RequestHeader("token") String token) {
        return userInfoBiz.token(token);
    }

}
